<?php
require_once ROOT_PATH . 'lib/db/ConnectorFactory.php';
/**
 *
 * @return Ambigous <IConnector, NULL, unknown, multitype:>
 */
function getDBConn() {
	$cn = 'PdoConnector';
	$db [IConnector::CONN_HOSTNAME] = DB_URL;
	$db [IConnector::CONN_DATABASE] = DB_NAME;
	$db [IConnector::CONN_USERNAME] = DB_USR;
	$db [IConnector::CONN_PASSWORD] = DB_PWD;
	$db [IConnector::CONN_PERSISTENT] = DB_PCONN;
	$db [IConnector::CONN_DRIVER] = DB_PDO_DRIVER;
	$db [IConnector::CHAR_APPLICATION] = GG_APP_CHARSET;
	$db [IConnector::CHAR_DATABASE] = GG_DB_CHARSET;
	$dbOptions [IConnector::LOG_DEBUG] = false;
	$dbOptions [IConnector::PARAM_QUERIES] = true;
	
	$conn = ConnectorFactory::create ( $cn, $db, $dbOptions );
	
	if (! empty ( $conn )) {
		$conn->getLink ()->exec ( "SET NAMES " . GG_MYSQL_CHARSET );
	} else {
		GF::oops ( '<b>Create DB connection failed.</b>' );
	}
	return $conn;
}